/**
 * 
 * anthor liyingqi
 *  834777203@qq.com
 */
import { isMessageGo } from '@/utils/tool.js';


const routeInterceptor = () => {
  let list = ["navigateTo", "navigateBack", "redirectTo","switchTab"];
  list.forEach(item => {
    uni.addInterceptor(item, {
      invoke(e) { // 调用前拦截
        /**
         * 兼容单项目启动为H5情况 WXS 
         */
        if (!e.notInFrame) {
          console.log(e,'事件处理处理处理')
          isMessageGo({
            action: item,
            data: e.url,
            title: e.title || "货代",
            webview: e.webview || 'zWebView', // uniapp app webview加载名称
          })
          return false
        }
        return true
      },
      fail(err) { // 失败回调拦截 
        console.log(err);
      },
    })
  })


}


export default routeInterceptor;

